<template>
    <el-container>
        <el-header>
            <el-row>
                目前可以检测 首页、创建比赛、运行代码、创建任务、任务完成
            </el-row>
            <el-row>
                <el-col :span="12">
                    15分钟自动检测一次
                </el-col>
                <el-col :span="12">
                    <el-button @click="apitest">手动检测</el-button>
                </el-col>
            </el-row>
        </el-header>
        <el-main>
            <div>上次检测时间：{{createdAt}}</div>
            <ul class="list-group">
                <li class="list-group-item" v-for="item in n">{{ item[0] }} &nbsp; {{ item[1]? '√': 'X' }}</li>
            </ul>
        </el-main>
    </el-container>
</template>

<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { useStore } from 'vuex';
import { fetchapi } from '../../../api';
import { Storekey } from '../../../interface';

const n = ref([
    [
        "首页",
        true
    ],
    [
        "创建比赛",
        true
    ],
    [
        "创建任务",
        true
    ],
    [
        "运行代码",
        true
    ],
    [
        "任务完成",
        true
    ]
])

const createdAt = ref<string>()

onMounted(() => {
    fetchapi('/studycode/v1/admin/autotest').then(e=> {
        n.value = e.data
        createdAt.value = new Date(e.createdAt).toLocaleString()
    })
})



const store = useStore(Storekey)

function apitest() {
    n.value = []
    store.state.socket.emit('apitest', (e: any) => {
        n.value = e
        createdAt.value = new Date().toLocaleString()
    })
}

</script>


<style scoped >
</style>